<?php
echo '<div id="navigator"><a href=""><img src="images/home.png" alt="Thiên Long mobile" /></a>'.$tc->navigator($row_menu_one['id']).'</div>';

$qr = $tc->menu($row_menu_one['id']);
if(mysql_num_rows($qr) > 1){
	echo '<div id="home_product"><h1>'.$row_menu_one['title'].'</h1><h2>'.$row_menu_one['metaDescription'].'</h2>';
	while($row = mysql_fetch_array($qr)){
		echo '<div style="clear:both; height:30px; line-height:30px; font-size:130%; color:#0072FF; margin:0 447px 5px 0; border-bottom:solid 3px #0072FF">'.$row['name'].'</div>';
		$qr2 = $tc->product_theomuc($row['id'],9);
		$total = mysql_num_rows($qr2);
		while($row2 = mysql_fetch_array($qr2)){
			if($row2['price']!=0) $price = number_format($row2['price'],0,',','.').'<sup> <u>đ</u></sup>'; else $price = 'Liên hệ';
			echo '<div class="item_product" style="width:200px; margin:0 13px 13px 0">
				<a href="'.$tc->link_detail($row2['menu_id']).$row2['name_rewrite'].'.html"><p class="img_product" style="background:url('.url_product_thumb.$row2['url_hinh'].') no-repeat center">'.$tc->type_noibat($row2['noibat']).'</p>
				<h3>'.$row2['name'].'</h3></a>
				<div class="price_product">'.$price.'</div>
			</div>';
		}
		if($total > 9) $view_more = '<a href="'.$row['url'].'" style="color:#FF8A00">Xem thêm..</a>'; else $view_more = '&nbsp;';
		echo '<div style="clear:both; font-size:95%; font-weight:bold; margin-bottom:10px; padding-right:20px; text-align:right">'.$view_more.'</div>';
	}
	echo '</div>';
}else{
	$from = (($page - 1) * max_product);
	$select = 'name,name_rewrite,url_hinh,menu_id,price,noibat';
	$table = 'products';
	$where = "`delete`=0 AND status=1 AND menu_id LIKE '%,{$idMenu},%'";
	$limit = "LIMIT {$from},".max_product;
	$list = $tc->list_item($select,$table,$where,$limit);
	$total = mysql_num_rows($list);
	
	if($total > 1){
		echo '<div id="home_product"><h1>'.$row_menu_one['title'].'</h1><h2>'.$row_menu_one['metaDescription'].'</h2>';
		while($row = mysql_fetch_array($list)){
			if($row['price']!=0) $price = number_format($row['price'],0,',','.').'<sup> <u>đ</u></sup>'; else $price = 'Liên hệ';
			echo '<div class="item_product" style="width:200px; margin:0 13px 13px 0">
				<a href="'.$tc->link_detail($row['menu_id']).$row['name_rewrite'].'.html"><p class="img_product" style="background:url('.url_product_thumb.$row['url_hinh'].') no-repeat center">'.$tc->type_noibat($row['noibat']).'</p>
				<h3>'.$row['name'].'</h3></a>
				<div class="price_product">'.$price.'</div>
			</div>';
		}
		$phantrang = $tc->phantrang($row_menu_one['url'],$page,max_product,'id',$table,$where);
		$phantrang = '<div id="phantrang">'.$phantrang.'</div>';
		echo $phantrang.'</div>';
	}elseif($total==1){
		$row = mysql_fetch_array($list);
		header('location: http://'.$domain.'/'.$tc->link_detail($row['menu_id']).$row['name_rewrite'].'.html');
	}else echo '<div style="clear:both; padding:30px; width:600px; height:300px; float:left">Thông tin đang được cập nhật...</div>';
}

include_once('blocks/right.php');